<template>
  <div>
    <el-button type="primary" @click="$emit('make',multipleSelection)">{{btnText}}</el-button>
    <el-table :data="tableData" size="mini" @selection-change="handleSelectionChange" fit highlight-current-row>
      <el-table-column type="selection"></el-table-column>
      <el-table-column v-for="(th, key) in tableHeader" :key="key"
                       :sortable="th.sortable" :property="th.prop" :label="th.label"
                       :fixed="th.fixed" :min-width="th.minWidth" align="center">
          <template slot-scope="scope">
            <div v-if="th.oper">
              <el-button v-for="(o, key) in th.oper" :key="key" @click="customEven(o.clickFun,scope.row)" type="text"
                         size="small">
                {{o.name}}
              </el-button>
            </div>
            <div v-else>
              <span>{{ scope.row[th.prop] }}</span>
            </div>
          </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        multipleSelection: []
      }
    },
    props: {
      tableHeader: {
        type: Array,
        required: true
      },
      tableData: {
        type: Array,
        required: true
      },
      btnText: {
        type: String,
        required: true
      }
    },
    methods: {
      handleSelectionChange(val) {
        this.multipleSelection = val;
      }
    }
  }
</script>

<style scoped>
  button {
    margin-bottom: 5px;
  }
</style>
